﻿using FluentNHibernate.Mapping;
using MadMediaManager.Core.Domain;

namespace MadMediaManager.DataAccess.Mappings
{
    public class SoftwareIsoMap : SubclassMap<SoftwareIso>
    {
        public SoftwareIsoMap()
        {
            Map(i => i.Publisher)
                .Length(50)
                .Nullable();

            Map(i => i.Version)
                .Length(50)
                .Nullable();

            Map(i => i.Architecture)
                .CustomType(typeof(Architecture))
                .Nullable();

            Map(i => i.Platform)
                .CustomType(typeof(Platform))
                .Nullable();

            Map(i => i.ProductFamily)
                .Length(50)
                .Nullable();
            
            HasMany(i => i.Licenses)
                .AsBag()
                .Inverse()
                .LazyLoad()
                .Access.CamelCaseField(Prefix.Underscore)
                .Cascade.AllDeleteOrphan();
        }
    }
}
